"""This module contains constants used by other modules."""

__author__ = "Gabriel Taubman (gtaubman@mac.com)"

import os
import unittest

"""The character representing a blank scrabble piece.

It must be a non-alphabetical character, otherwise it will interfere with other
alphabetical tiles.
"""
BLANK_TILE = "_"

"""How many tiles a player can have at once."""
TILES_IN_HAND = 7

"""Score bonus for a successful move with all TILES_IN_HAND tiles."""
BINGO_BONUS = 50

"""The minimum and maximum number of players in a game."""
MIN_PLAYERS_IN_GAME = 2
MAX_PLAYERS_IN_GAME = 4

"""The name of the database file."""
DATABASE_FILE = "scrabble.db"

"""The maximum size in bytes of a player file."""
MAX_PLAYER_FILE_SIZE = 80 * 10000

"""The key for storing a user's username in a session."""
USERNAME_SESSION_KEY = "_cp_username"

class ConstantsTest(unittest.TestCase):
  def TestIntGTZero(self, value):
    self.assert_(type(value) == int)
    self.assert_(value > 0)

  def TestNonEmptyString(self, string):
    self.assert_(len(string) > 0)

  def testBlankTile(self):
    self.assert_(not BLANK_TILE.isalpha())
    self.assert_(len(BLANK_TILE) == 1)

  def testTilesInHand(self):
    self.TestIntGTZero(TILES_IN_HAND)

  def testBingoBonus(self):
    self.TestIntGTZero(BINGO_BONUS)

  def testMaxPlayerFileSize(self):
    self.TestIntGTZero(MAX_PLAYER_FILE_SIZE)


  # String constants.
  def testDatabaseFile(self):
    self.TestNonEmptyString(DATABASE_FILE)

  def testUsernameSessionKey(self):
    self.TestNonEmptyString(USERNAME_SESSION_KEY)

if __name__ == "__main__":
  unittest.main()
